<div class="maintop">
    当前位置：代理用户管理
    <a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($page_current,$page_url)?>" id="btn_refresh" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
</div>
<div class="main-search">
    <table width="100%">
        <tbody><tr>
            <td>
                <form action="<?=$basepath?>" id="SearchForm" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                    <select name="agentLevel">
                        <option value="">代理等级</option>
                        <? foreach($agentLevel as $k=>$v){ ?>
                            <option value="<?=$k?>"><?=$v?></option>
                        <? } ?>
                    </select>
                    <select name="sortfield" id="sortfield">
                        <option value="">默认</option>
                        <option value="regtimes">注册时间</option>
                        <option value="recharge">充值</option>
                        <option value="cash">提现</option>
                        <option value="directlys">直属人数</option>
                        <option value="directlysrecharge">直属充值</option>
                        <option value="directlyscash">直属提现</option>
                        <option value="directlysprofit">直属盈亏</option>
                        <option value="teams">团队人数</option>
                    </select>
                    <select name="sorttype" id="sorttype">
                        <option value="DESC">倒序</option>
                        <option value="ASC">正序</option>
                    </select>
                    <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字">
                    注册日期：从
                    <input id="fromTime" name="fromTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['fromTime']?date('Y-m-d',intval(strtotime($searchdata['fromTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;至
                    <input id="toTime" name="toTime" type="text" class='Wdate' style='width:100px;' value="<?=$searchdata['toTime']?date('Y-m-d',intval(strtotime($searchdata['toTime']))):''?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"></input>&nbsp;&nbsp;
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input type="submit" value="搜索" class="upbutton">
                    <input action="<?=$basepath?>_delete_list" type="button" id="deleteSelectId" value="删除选择" class="upbutton">
                </form>
            </td>
        </tr>
        </tbody>

    </table>
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg">
            <th>No.</th>
			<th>充</th>
			<th>玩家号码</th>
            <th>玩家昵称</th>
            <th>等级</th>
            <th>余额</th>
            <th>充值</th>
            <th>提现</th>
            <th>返点</th>
            <th>佣金</th>
            <th>直属</th>
            <th>直属充</th>
            <th>直属提</th>
            <th>直属盈亏</th>
            <th>团队</th>
            <th width="130">注册时间</th>
            <th width="90">操作</th>
        </tr>
        <? foreach($datas as $v){ ?>
            <tr<?=($v['isdelete']?' class="delete"':'')?>>
                <td><a href="javascript:;" action="/box/mail_add_pop?touid=<?=$v['uid']?>" class="mainFrame" title="发送站内信"><?=$v['uid']?></a></td>
				<td width="20"><a href="/members/rechargetouser?uno=<?=$v['uno']?>" class="button fa fa-cny" target="ajax" func="loadpage" title="给玩家充值"></a></td>
                <td><a href="javascript:;" action="/box/mail_push_pop?uno=<?=$v['uno']?>&nickname=<?=$v['nickname']?>" class="mainFrame" title="推送信息"><?=$v['uno']?></a></td>
                <td><?=$v['nickname']?></td>
                <td><?=(isset($agentLevel[$v['agentlevel']]) ? $agentLevel[$v['agentlevel']] : '')?></td>
                <td style="text-align:right"><?=$v['coin']?></td>
                <td style="text-align:right"><?=($v['recharge']>0?$v['recharge'] :'')?></td>
                <td style="text-align:right"><?=($v['cash']>0?$v['cash'] :'')?></td>
                <td style="text-align:right"><?=($v['commission']<>0?$v['commission']:'')?></td>
                <td style="text-align:right"><?=($v['rebate']>0?$v['rebate'].'%':'')?></td>
                <td><a href="javascript:;" action="/members/members_list?puid=<?=$v['uid']?>&t=1" class="mainFrame"><?=($v['directlys']>0?$v['directlys']:'')?></a></td>
                <td style="text-align:right"><?=($v['directlysrecharge']<>0?$v['directlysrecharge'] :'')?></td>
                <td style="text-align:right"><?=($v['directlyscash']<>0?$v['directlyscash'] :'')?></td>
                <td style="text-align:right"><?=($v['directlysprofit']<>0?$v['directlysprofit'] :'')?></td>
                <td><a href="javascript:;" action="/members/members_list?puid=<?=$v['uid']?>&t=2" class="mainFrame"><?=($v['teams']>0?$v['teams']:'')?></a></td>
                <td><?=date('Y-m-d H:i:s',$v['regtimes'])?></td>
                <td>
                    <? if($v['isdelete']){ ?>
                        <a action="<?=$basepath?>_recovery?uid=<?=$v['uid']?>" title="恢复" class="mainFrame button icon-undo" href="javascript:;"></a>
                    <? }else{ ?>
                    <a action="<?=$basepath?>_delete?uid=<?=$v['uid']?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
                    <? } ?>
                    <a href="/members/members_list_edit?uid=<?=$v['uid']?>" title="编辑 - <?=$v['nickname']?>" class="colorbox button icon-edit"></a>
                    <a href="/members/agentuser_list_edit?uid=<?=$v['uid']?>" title="<?=$v['nickname']?> - 统计" class="colorbox button icon-table"></a>
                </td>
            </tr>
        <? } ?>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){

    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['usergroup'])){
            echo '$("#usergroup option[value='.$searchdata['usergroup'].']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sortfield'])){
            echo '$("#sortfield option[value='.$searchdata['sortfield'].']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sorttype'])){
            echo '$("#sorttype option[value='.$searchdata['sorttype'].']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>
        $(".colorbox").colorbox({ iframe: true,width:"80%",height:"80%" });
    });
</script>
